package cn.lopr.im.socketserver.constant;

/**
 * @author shuangyang7
 * @date 2020/12/28 14:55
 */
public class Constant {

    public enum ResponseCode {
        SUCCESS(0, "success"),
        ERROR(1, "error"),
        NEED_LOGIN(10, "NEED_LOGIN"),
        ILLEGAL_ARGUMENT(2, "ILLEGAL_ARGUMENT");

        int code;
        String desc;

        ResponseCode(int code, String desc) {
            this.code = code;
            this.desc = desc;
        }

        public int getCode() {
            return code;
        }

        public String getDesc() {
            return desc;
        }

        public static String getDescByCode(int errorCode) {
            for (ResponseCode value : values()) {
                if (value.code == errorCode) {
                    return value.desc;
                }
            }
            return null;
        }
    }
}
